/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package src.report.saving;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import org.primefaces.context.RequestContext;
import org.primefaces.event.CloseEvent;
import src.Menu;
import src.MenuBean;
import src.domain.customer.Customer;
import src.report.ReportCfgModel;
import src.report.ReportFilter;
import src.util.Messager;

/**
 *
 * @author Yusup Jauhari Shandi <in.visi>
 */
@ManagedBean
@SessionScoped
public class SavReportBean implements Serializable{
    private List<Menu> availableMenu;
    private Menu SelectedReport;
    private ReportFilter reportFilter;
    
    private boolean showLookup=false;
    
    public SavReportBean() {
        MenuBean menuBean = new MenuBean();
        Map<String,Object> filters = new HashMap<>();
        reportFilter = new ReportFilter();
        filters.put("menuType", "report");
        filters.put("menuGroup", "SAVING");
        filters.put("hide", -1);
        
        availableMenu = menuBean.getMenuByType(filters);
        this.SelectedReport = new Menu(-1, null, null, null, null, null, null, Integer.SIZE, null);
    }

    public ReportFilter getReportFilter() {
        return reportFilter;
    }

    public void setReportFilter(ReportFilter reportFilter) {
        this.reportFilter = reportFilter;
    }
    
    

    public List<Menu> getAvailableMenu() {
        return availableMenu;
    }

  

    
    public Menu getSelectedReport() {        
        return SelectedReport;
    }

    public void setSelectedReport(Menu SelectedReport) {
        this.SelectedReport = SelectedReport;
    }
    
    public void executeReport(){
        Integer reportId = this.SelectedReport.getMenuId();
        /*  131 : rptTransaksiTabungan
         *  132 : rptNominatifTabungan
         *  133 : rptSimpananPihak3 
         */
        
        switch (reportId) {
            case 131 : 
                new RptTransaksiTabunganBean().execute(reportFilter);
            break;
            case 132 : new RptNominatifTabunganBean().execute(reportFilter);break;
            case 133 : new RptSimpananPihak3Bean().execute(reportFilter);break;
        }
    }

    public boolean isShowLookup() {
        return showLookup;
    }

    public void setShowLookup(boolean showLookup) {
        this.showLookup = showLookup;
    }
    
    
    public void showDialog(String value) {
        value+=".show();";
        RequestContext.getCurrentInstance().execute(value);
    }
    
       public void handleCloseLookup(CloseEvent event) {
        this.showLookup=false;
    }
       
       
    public void prepareCif(String cif) {
        reportFilter.setCif(cif);
    }
}
